﻿namespace Sidvall.WorkItemManager.Net.Services.V1
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class WebTarget : global::Sidvall.Data.ServiceDataRowBase, global::Sidvall.WorkItemManager.Data.IWebTarget
    {
        #region Public Members

        #region Content

        private string _Content;
        partial void OnBeforeContentPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterContentPropertyChanged();
        public string Content
        { 
            get
            {
                return _Content;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _Content = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Content);
                    OnBeforeContentPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("Content", eventData.Value, true, true);
                        OnAfterContentPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region HttpVerb

        private string _HttpVerb;
        partial void OnBeforeHttpVerbPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterHttpVerbPropertyChanged();
        public string HttpVerb
        { 
            get
            {
                return _HttpVerb;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _HttpVerb = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _HttpVerb);
                    OnBeforeHttpVerbPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("HttpVerb", eventData.Value, true, true);
                        OnAfterHttpVerbPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled;
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        { 
            get
            {
                return _IsEnabled;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _IsEnabled = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                    OnBeforeIsEnabledPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("IsEnabled", eventData.Value, true, true);
                        OnAfterIsEnabledPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region WebAddress

        private string _WebAddress;
        partial void OnBeforeWebAddressPropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterWebAddressPropertyChanged();
        public string WebAddress
        { 
            get
            {
                return _WebAddress;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _WebAddress = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _WebAddress);
                    OnBeforeWebAddressPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("WebAddress", eventData.Value, true, true);
                        OnAfterWebAddressPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region WebContextId

        private int _WebContextId;
        partial void OnBeforeWebContextIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<int> eventData);
        partial void OnAfterWebContextIdPropertyChanged();
        public int WebContextId
        { 
            get
            {
                return _WebContextId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _WebContextId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<int> eventData = new Sidvall.Business.PropertyChangeEventData<int>(value, _WebContextId);
                    OnBeforeWebContextIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("WebContextId", eventData.Value, true, true);
                        OnAfterWebContextIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region WebTargetId

        private System.Nullable<int> _WebTargetId;
        partial void OnBeforeWebTargetIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData);
        partial void OnAfterWebTargetIdPropertyChanged();
        public System.Nullable<int> WebTargetId
        { 
            get
            {
                return _WebTargetId;
            }
            set
            {
                if (this.BusinessSettings.EnabledBusinessEvents == Sidvall.Business.BusinessEvents.None)
                {
                    _WebTargetId = value;
                }
                else
                {
                    Sidvall.Business.PropertyChangeEventData<System.Nullable<int>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<int>>(value, _WebTargetId);
                    OnBeforeWebTargetIdPropertyChanged(eventData);
                    if (!eventData.Cancel)
                    {
                        LoadInstanceField("WebTargetId", eventData.Value, true, true);
                        OnAfterWebTargetIdPropertyChanged();
                    }
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowStateIsDirty

        protected override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.DataRowStateIsDirty(this);
            }
        }

        #endregion
        
        public WebContext WebContext { get; set; }
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool updateState)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.LoadInstanceField(this, fieldName, value, cascade, false, updateState);
        }

        #endregion
        #region Copy

        public WebTarget Copy()
        {
            return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.Copy(this);
        }
        public WebTarget Copy(Sidvall.Data.CopySettings settings)
        {
            return global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.Copy(this, settings);
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.WorkItemManager.Data.IWebTarget item)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.Import(this, item);
        }
        public void Import(global::Sidvall.WorkItemManager.Data.IWebTarget item, Sidvall.Data.CopySettings settings)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.Import(this, item, settings);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.ValidateAsync(this).ConfigureAwait(false);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            return await global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.ValidateAsync(this, settings).ConfigureAwait(false);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.Initialize(this, settings);
        }

        #endregion

        #region IWebTarget Members

        string global::Sidvall.WorkItemManager.Data.IWebTarget.Content
        {
            get
            {
                return this._Content;
            }
            set
            {
                this._Content = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWebTarget.HttpVerb
        {
            get
            {
                return this._HttpVerb;
            }
            set
            {
                this._HttpVerb = value;
            }
        }
        bool global::Sidvall.WorkItemManager.Data.IWebTarget.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        string global::Sidvall.WorkItemManager.Data.IWebTarget.WebAddress
        {
            get
            {
                return this._WebAddress;
            }
            set
            {
                this._WebAddress = value;
            }
        }
        int global::Sidvall.WorkItemManager.Data.IWebTarget.WebContextId
        {
            get
            {
                return this._WebContextId;
            }
            set
            {
                this._WebContextId = value;
            }
        }
        System.Nullable<int> global::Sidvall.WorkItemManager.Data.IWebTarget.WebTargetId
        {
            get
            {
                return this._WebTargetId;
            }
            set
            {
                this._WebTargetId = value;
            }
        }
        global::Sidvall.WorkItemManager.Data.IWebContext global::Sidvall.WorkItemManager.Data.IWebTarget.WebContext
        {
            get
            {
                return this.WebContext;
            }
            set
            {
                this.WebContext = (WebContext)value;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public WebTarget()
        {
        }
        public WebTarget(bool initializeDefaultValues)
            : this(initializeDefaultValues, null, Sidvall.Business.BusinessEvents.None)
        {
        }
        public WebTarget(bool initializeDefaultValues, Sidvall.Data.DataRowState? dataRowState, Sidvall.Business.BusinessEvents enabledBusinessEvents)
            : base(dataRowState, enabledBusinessEvents)
        {
            if (initializeDefaultValues)
                global::Sidvall.WorkItemManager.SystemContextConfig.Current.EntityFacade.WebTargetManager.Initialize(this);
        }

        #endregion
    }
}